import axios from 'axios'
import {getStorge} from '@/router/helper.js'
import qs from 'qs'
// import dev from '../../config/index'
const instance = axios.create({
  baseURL:process.env.VUE_APP_BASE_API,
  timeout:50000
})

// 请求拦截
instance.interceptors.request.use(
  config =>{
    console.log(config,'112223')
    if(config.url!='/login'&&config.url!='/registered'){//读取本地
      console.log('jinlai')
    const getStorgeName =  getStorge('token')
    const token = {Authorization:getStorgeName}
    console.log(token,'666')
      config.headers =Object.assign({},config.headers,token)
      //  console.log( config.data )
       console.log( config,6667777 )
    }
    console.log(config,990)
    return config
  },
  error=>{
    return Promise.reject(error)
  }
)
instance.interceptors.response.use(response=>{
  console.log(response,'response')
  if(response.data.code == 200){
    return Promise.resolve(response.data)
  }else {
    return Promise.reject(response.data)
  }

})
export default instance
